import {
    createRouter,
    createWebHashHistory
} from 'vue-router'

const routes = [
    {
        path: '/',
        name: 'login',
        component: () => import('../pages/login/index.vue')
    },
    {
        path: '/home',
        name: 'home',
        component: () => import('../pages/home/index.vue'),
        //二级路由
        children: [ // （子路由 需要在父页面 放置 <router-view /> 标签）
            {
                path: '/home',
                name: 'home',
                component: () => import('../pages/views/view.vue'),
            }, {
                path: 'view1',
                name: 'view',
                component: () => import('../pages/views/view.vue'),
            }, {
                path: 'view2',
                name: 'view2',
                component: () => import('../pages/views/view2.vue'),
            }
        ],
        //路由守卫
        // beforeEnter: (to: any, from: any, next: any) => {
        // if (window.localStorage.getItem('islogin') == "true") {
        //     next()//返回 不加反不回去
        // } else {
        //     alert("请先登录")
        //     next('/')//返回 不加反不回去
        // }
        // }
    },

]
const router = createRouter({
    history: createWebHashHistory(),
    routes
})
export default router